import { configureStore, combineReducers } from '@reduxjs/toolkit';
import { TypedUseSelectorHook, useSelector, useDispatch } from 'react-redux';

import global from './global';
import user from './user';
import listBase from './list/base';
import listSelect from './list/select';
import listCard from './list/card';
import goods from './goods';
// eslint-disable-next-line camelcase
import course_selection from './course_selection';
import order from './order';

const reducer = combineReducers({
  global,
  user,
  listBase,
  listSelect,
  listCard,
  goods,
  // eslint-disable-next-line camelcase
  course_selection,
  order,
});

export const store = configureStore({
  reducer,
});

export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

export const useAppDispatch = () => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;

export default store;
